<template>
  <div>
    <div class="content mb-25">
      <div class="cause mb-25">
        <div>异常原因：{{dataInfo.reason}}</div>
      </div>
      <div class="reason mb-20">
        <div class="title mb-10">申诉理由</div>
        <div>{{dataInfo.account}}</div>
      </div>
      <div class="prove">
        <div class="title mb-10">证明文件</div>
        <el-image
          v-if="dataInfo.proveUrl.length"
          fit='fill'
          style="height: 200px;margin-left: 80px;"
          :src="dataInfo.proveUrl[0]"
          :preview-src-list="dataInfo.proveUrl">
        </el-image>
      </div>
    </div>
    <div class="dialog-foot">
      <el-button type="primary" @click="handleSave">已确认，申诉通过</el-button>
      <el-button type="primary" @click="handleVoid">申诉无效</el-button>
    </div>
  </div>
</template>

<script>
import { getPreventionAppeal, isEffectiveAdopt } from '@/views/children/antiepidemic/js/preventionRiskScreen'
export default {
  props: {
    rowData: {
      type: Object,
      require: true
    }
  },
  data () {
    return {
      dataInfo: {
        proveUrl: []
      },
      tenantNo: null
    }
  },
  created () {
    this.getPreventionAppeal()
  },
  mounted () {
    let userInfo = localStorage.getItem('Standard__User-Info')
    this.tenantNo = JSON.parse(userInfo).value.tenantNo
  },
  methods: {
    getPreventionAppeal () {
      getPreventionAppeal({ appeaId: this.rowData.appeaId }).then(res => {
        this.dataInfo = res.data || {}
        this.dataInfo.proveUrl = this.dataInfo.proveUrl.split(',').map(item => {
          return '/gateway/api/basic/minio/getFileSource?fileName=' + item
        })
      })
    },
    handleSave () {
      isEffectiveAdopt({ riskScreenId: this.rowData.id, tenantNo: this.tenantNo, isEffectiveType: 1, appealId: this.rowData.appeaId }).then(() => {
        this.$message.success('申诉成功')
        this.$emit('cancel', true)
      })
    },
    handleVoid () {
      isEffectiveAdopt({ riskScreenId: this.rowData.id, tenantNo: this.tenantNo, isEffectiveType: 0, appealId: this.rowData.appeaId }).then(() => {
        this.$message.success('申诉无效')
        this.$emit('cancel', true)
      })
    }
  }
}
</script>

<style lang='scss' scoped>
.dialog-foot {
  text-align: center;
}
.title {
  font-size: 18px;
  font-weight: 600;
}
</style>
